<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="">
        <table>
            <tr>
                <td>手机号</td>
                <td><input type="text" class="mobile"></td>
                <td></td>
            </tr>
            <tr>
                <td>邮箱</td>
                <td><input type="text" class="email"></td>
                <td></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="text" class="pwd"></td>
                <td></td>
            </tr>
            <tr>
                <td colspan="3">
                    <input type="submit" class="regist" value="注册" disabled>
                </td>

            </tr>
        </table>
    </form>
</body>

</html>
<script>
    // 表示三个表单的标识符 默认都不满足
    var mobile = email = pwd = false;
    document.querySelector('.mobile').onblur = function () {
        if (/^1[2-9]\d{9}$/.test(this.value)) {
            this.parentElement.nextElementSibling.innerHTML = '<span style="color:green">√</span>'
            mobile = true
        } else {
            this.parentElement.nextElementSibling.innerHTML = '<span style="color:red">×</span>'
            mobile = false;
        }
        changeRegistBtn();
    }
    // 验证码邮箱
    document.querySelector('.email').onblur = function () {
        if (/^\w{3,24}@(163|qq|126|sina)\.(com|cn)$/.test(this.value)) {
            this.parentElement.nextElementSibling.innerHTML = '<span style="color:green">√</span>'
            email = true;
        } else {
            this.parentElement.nextElementSibling.innerHTML = '<span style="color:red">×</span>'
            email = false;
        }
        changeRegistBtn();
    }
    // 验证码密码
    document.querySelector('.pwd').onblur = function () {
        if (this.value.length > 6 && this.value.length < 16 && /[A-Z]/.test(this.value) && /[a-z]/.test(this
                .value) && /\d/.test(this.value)) {
            this.parentElement.nextElementSibling.innerHTML = '<span style="color:green">√</span>'
            pwd = true;
        } else {
            this.parentElement.nextElementSibling.innerHTML = '<span style="color:red">×</span>'
            pwd = false;
        }
        changeRegistBtn();
    }
    // 修改注册按钮
    function changeRegistBtn() {
        document.querySelector('.regist').disabled = !(mobile && email && pwd);
    }
</script>